]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/powerProfiles: Remember last selected non-default profile
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 29 Jul 2022 18:00:18 +0000 (20:00 +0200)
committerMarge Bot <marge-bot@gnome.org>
Mon, 1 Aug 2022 12:33:36 +0000 (12:33 +0000)
When we move to quick settings, this will allow us to toggle
between two profiles even where more profiles are available.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2391>

data/org.gnome.shell.gschema.xml.in
js/ui/status/powerProfiles.js

index d3f3c702d22751f663eb56a4a75a0603a78072a4..c56a3399ebd5b3b5cffc7e47139952475a90f6ee 100644 (file)
         adapter is ever seen not to have devices associated to it.
       </description>
     </key>
+    <key name="last-selected-power-profile" type="s">
+      <default>"power-saver"</default>
+      <summary>The last selected non-default power profile</summary>
+      <description>
+        Some systems support more than two power profiles. In order to still support
+        toggling between two profiles, this key records the last selected non-default
+        profile.
+      </description>
+    </key>
     <key name="welcome-dialog-last-shown-version" type="s">
       <default>''</default>
       <summary>The last version the “Welcome to GNOME” dialog was shown for</summary>
index 9878abfaca673e7375e5dae514bae18735254556..f9a97a64fcbdd19651bd103dd752e17f4cdff1f9 100644 (file)
@@ -32,6 +32,8 @@ const PROFILE_PARAMS = {
     },
 };
 
+const LAST_PROFILE_KEY = 'last-selected-power-profile';
+
 var Indicator = GObject.registerClass(
 class Indicator extends PanelMenu.SystemIndicator {
     _init() {
@@ -101,14 +103,19 @@ class Indicator extends PanelMenu.SystemIndicator {
         if (!this._item.visible)
             return;
 
+        const {ActiveProfile: activeProfile} = this._proxy;
+
         for (const [profile, item] of this._profileItems) {
-            item.setOrnament(profile === this._proxy.ActiveProfile
+            item.setOrnament(profile === activeProfile
                 ? PopupMenu.Ornament.CHECK
                 : PopupMenu.Ornament.NONE);
         }
 
-        const {label, iconName} = PROFILE_PARAMS[this._proxy.ActiveProfile];
+        const {label, iconName} = PROFILE_PARAMS[activeProfile];
         this._item.label.text = label;
         this._item.icon.icon_name = iconName;
+
+        if (activeProfile !== 'balanced')
+            global.settings.set_string(LAST_PROFILE_KEY, activeProfile);
     }
 });